package com.example.trb.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.example.trb.entity.group.Insert;
import com.example.trb.entity.group.Update;
import com.example.trb.validation.DateTime;
import lombok.Data;

import javax.validation.constraints.*;
import java.util.Date;
import java.util.List;

@Data
@TableName(autoResultMap = true)
public class PerformanceAward {
    @TableId(type = IdType.AUTO)
    private Integer id;

    @NotNull(groups = {Insert.class})
    @Null(groups = {Update.class})
    private Integer reviewFormId;

    @NotBlank(message = "项目名称不能为空", groups = {Update.class, Insert.class})
    private String name;

    @NotBlank(message = "颁奖等级不能为空", groups = {Update.class, Insert.class})
    @Pattern(regexp = "一等|二等|三等", groups = {Update.class, Insert.class})
    private String level;

    @DateTime(message = "颁奖时间不能为空", groups = {Update.class, Insert.class})
    private String grantTime;

    @NotBlank(message = "授予机构不能为空", groups = {Update.class, Insert.class})
    private String grantingInstitution;

    @NotBlank(message = "颁奖原因不能为空", groups = {Update.class, Insert.class})
    private String summery;

    @Size(min = 1, message = "业绩奖励证明材料至少要有一个", groups = {Update.class, Insert.class})
    @Size(max = 3, message = "业绩奖励材料最多只能有三个", groups = {Update.class, Insert.class})
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private List<String> materials;

    @Pattern(regexp = "待审核|未通过|已通过")
    private String status;
}
